

import 'package:flutter_my_web/net/BaseResponse.dart';

class GetTextResponse extends BaseResponse{
  List<TextResponse> data=[];

  @override
  fromJson(Map<String, dynamic>? json) {
    super.fromJson(json);
    List dataList = json?["data"];
    dataList.forEach((element) {
      data.add(TextResponse()..fromJson(element));
    });
  }

}
class TextResponse extends BaseResponse{
  String? id;
  String? title;
  String? desc;
  String? coverUrl;
  String? tags;
  String? createTime;
  String? changeTime;
  String? type;
  String? content;

  @override
  fromJson(Map<String, dynamic>? json) {
    super.fromJson(json);
    if(json?["data"]!=null){
      this.id = json?["data"]['id'];
      this.title = json?["data"]['title'];
      this.desc = json?["data"]['desc'];
      this.coverUrl = json?["data"]['coverUrl'];
      this.tags = json?["data"]['tags'];
      this.createTime = json?["data"]['createTime'];
      this.changeTime = json?["data"]['changeTime'];
      this.type = json?["data"]['type'];
      this.content = json?["data"]['content'];
    }else{
      this.id = json?['id'];
      this.title = json?['title'];
      this.desc = json?['desc'];
      this.coverUrl = json?['coverUrl'];
      this.tags = json?['tags'];
      this.createTime = json?['createTime'];
      this.changeTime = json?['changeTime'];
      this.type = json?['type'];
      this.content = json?['content'];
    }

  }
  List tagList(){
    if(tags!=null && tags!.isNotEmpty){
      return tags!.split(",");
    }else{
      return [];
    }
  }

  @override
  String toString() {
    return '------------------------\n{id: $id, title: $title, desc: $desc, coverUrl: $coverUrl, tags: $tags, createTime: $createTime, changeTime: $changeTime, type: $type, content: $content}\n\n\n';
  }
}